import 'package:flutter/material.dart';
import 'dart:math';

class TextFieldPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return TextFieldPageState();
  }
}

class TextFieldPageState extends State<TextFieldPage> {
  Color _randomColor() {
    var red = Random.secure().nextInt(255);
    var greed = Random.secure().nextInt(255);
    var blue = Random.secure().nextInt(255);
    return Color.fromARGB(255, red, greed, blue);
  }

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: Text("TextField Example"),
        ),
        body: Column(
          children: <Widget>[
            Text('基本输入框：',
                style:
                    TextStyle(fontSize: 15.5, height: 1.2, color: Colors.blue),
                textAlign: TextAlign.left),
            TextField(),
            Divider(),
            TextField(
              keyboardType: TextInputType.number,
              decoration: InputDecoration(
                contentPadding: EdgeInsets.all(10.0),
                icon: Icon(Icons.face),
                labelText: '请输入你的意见)',
                helperText: '匿名评论',
              ),
              onChanged: (String str) => print(str),
              autofocus: false,
              maxLines: 5,
            ),
            Divider(),
            Text("i'm a text"),
            Divider(),
            RichText(
              text: TextSpan(
                text: 'Hello ',
                style: TextStyle(
                    fontWeight: FontWeight.bold, color: Colors.orange),
                children: <TextSpan>[
                  TextSpan(
                      text: 'bold',
                      style: TextStyle(
                          fontWeight: FontWeight.bold, color: Colors.red)),
                  TextSpan(
                      text: ' world!',
                      style: TextStyle(fontStyle: FontStyle.italic)),
                ],
              ),
            ),
          ],
        ));
  }
}
